<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>案件收支录入</title>
    <link rel="stylesheet" href="../../layuiadmin/js/finance/js/bootstrap/css/bootstrap.min.css" />
    <script type="text/javascript" src="../../layuiadmin/js/finance/js/jquery.min.js" ></script>
    <script type="text/javascript" src="../../layuiadmin/js/finance/js/bootstrap/js/bootstrap.js" ></script>
    <script>

            $(document).ready(function(){
                var GRP=getlist();
                var caseid=GRP['caseid'];
                var overpay=GRP['overpay'];
                if(caseid!=null&&caseid!=''&&overpay!=null&&overpay!=''){
                    var caseid=$("#caseid").val(caseid);
                    var overpay=$("#overpay").text(overpay);
                }
                var myDate = new Date();
                //获取当前年
                var year=myDate.getFullYear();
                //获取当前月
                var month=myDate.getMonth()+1;
                //获取当前日
                var date=myDate.getDate();
                if(date<10){
                    date="0"+date;
                }
                var now=year+'-'+month+"-"+date;
                //收款金额
                var incomedate=$("#incomedate").val(now);
                demo();
            });
            function demo() {
                var sel=$("#sel").val();
                var name=$("#name").val();
                $.post("http://localhost:8080/financePayoutController/caselawlist",
                    {"name":name,"sel":sel},
                    function(msg){
                        var tab=$("#tab");
                        if (msg.length == 0) {
                            $("#tab  tr:not(:first)").remove();
                            var tr = $("<tr></tr>");
                            var td = $("<td colspan='7'>没有相关数据</td>");
                            tr.append(td);
                            tab.append(tr);
                        }else {
                            $("#tab  tr:not(:first)").remove();
                            for(var i=2;i<msg.length;i++){
                                var tr = $("<tr></tr>");
                                var td = $("<td><input type='radio' id='ca'  name='an' ></td>");
                                var td1 = $("<td>" + msg[i].caseId + "</td>");
                                var td2 = $("<td>" + msg[i].clientId.clientName + "</td>");
                                var td3 = $("<td>" + msg[i].oppositeId.clientName + "</td>");
                                var td4 = $("<td>" + msg[i].mainLawyer.empName + "</td>");
                                var td5 = $("<td>" + msg[i].closeDate + "</td>");
                                var td6=$("<td class='hidden'>"+msg[i].amountMoney+"</td>");
                                tr.append(td);
                                tr.append(td1);
                                tr.append(td2);
                        tr.append(td3);
                        tr.append(td4);
                        tr.append(td5);
                        tr.append(td6);
                        tab.append(tr);
                    }
            }
                    });
            }
            function  check(){
                var caseid1= $('input[name="an"]:checked').parent().parent().find("td").eq(1).text();
                var caseid=$("#caseid").val(caseid1);
                var overpay1= $('input[name="an"]:checked').parent().parent().find("td").eq(6).text();
                var overpay=$("#overpay").text(overpay1+"(元)");
            }
            function  show() {
                var incomedate=$("#incomedate").val();
                var caseid=$("#caseid").val();
                var overpay=$("#overpay").text();
                if(caseid!=null&&caseid!=''){
                    window.location.href = "../../views/finance/next1.html?caseid="+caseid+"&overpay="+overpay+"";
                }else{
                    var span=$("#show").text("请选择案件");
                }
            }
            function getlist() {
                var url = location.search; //获取url中"?"符后的字串
                var theRequest = new Object();
                if (url.indexOf("?") != -1) {
                    var str = url.substr(1);
                    var strs = str.split("&"); //将所有参数拆分放入数组
                    for (var i = 0; i < strs.length; i++) {  //遍历参数数组
                        theRequest[strs[i].split("=")[0]] = decodeURIComponent(strs[i].split("=")[1]);
                    }
                }
                return theRequest;
            }


    </script>
</head>
<body>
<div class="container-fluid">
    <form class="form-horizontal form-inline" >
        <div style="margin-top: 15px" id="div1">
            <div class="row">
                <div class="col-lg-12">
                    <div class="col-lg-1"></div>
                    <div class="col-lg-11">
                        <font style="font-size: 20px"><strong>|案件收支</strong></font><br>
                    </div>
                </div>
                <div class="col-lg-12">
                    <br>
                    <div class="col-lg-1"></div>
                    <div class="col-lg-5">
                        <label><font style="color: red">*</font>案件</label>
                        <br>
                        <input type="text"  data-toggle="modal" data-target="#mt" class="form-control" style="width:100%" id="caseid" readonly="readonly">
                        <font style="color: red"><span id="show"></span></font>
                    </div>
                    <div class="col-lg-6">
                        <label><font style="color: red">*</font>应付款</label>
                        <br>
                        <span id="overpay"></span>
                    </div>
                </div>
                <div class="col-lg-12">
                    <br>
                    <div class="col-lg-1"></div>
                    <div class="col-lg-5">
                        <label for="incomemoney"><font style="color: red">*</font>收款金额</label>
                        <br>
                        <input type="text" id="incomemoney" class="form-control" style="width: 100%">
                    </div>
                    <div class="col-lg-6">
                        <label for="incomedate"><font style="color: red">*</font>收款日期</label>
                        <br>
                        <input type="text" id="incomedate" class="form-control" style="width: 100%" readonly="readonly">
                    </div>
                </div>
                <div class="col-lg-12">
                    <br>
                    <div class="col-lg-1"></div>
                    <div class="col-lg-11">
                        <button type="button" class="btn btn-success" onclick="show()">下一步</button>
                    </div>
                </div>
            </div>
        </div>
        <div class="modal"  id="mt">
            <div class="modal-dialog modal-lg">
                <div class="modal-content">
                    <div class="modal-header">
                        <span>选择案件</span>
                        <button class="close" data-dismiss="modal">
                            <span>&times;</span>
                        </button>
                    </div>
                    <div class="modal-body" style="height: 500px">
                        <div class="row"  style="padding-left: 20px" >
                                    <input type="text" class="form-control" id="name"/>
                                    <select class="form-control" id="sel">
                                        <option value="-1">请选择</option>
                                        <option value="1">案号搜索</option>
                                        <option value="2">承办律师搜索</option>
                                        <option value="3">委托人搜索</option>
                                        <option value="4">对方当事人搜索</option>
                                        <option value="5">案由搜索</option>
                                        <option value="6">受理法院搜索</option>
                                    </select>&nbsp;&nbsp;
                                    <input type="button" class="btn btn-success" value="搜索" onclick="demo()"/>
                        </div>
                        <div class="row"  style="padding-left: 20px;margin-top: 30px;" >
                            <table style="width: 97%;border: none;text-align: center" border="1px" id="tab">
                                <tr style="height: 50px">
                                    <td><b>选择</b></td>
                                    <td><b>案件号</b></td>
                                    <td><b>委托人</b></td>
                                    <td><b>对方当事人</b></td>
                                    <td><b>承办律师</b></td>
                                    <td><b>收案日期</b></td>
                                </tr>
                            </table>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <input type="button" class="btn btn-success"  value="确定" data-dismiss="modal" onclick="check()">
                        <input type="button" class="btn btn-success" value="关闭" data-dismiss="modal">
                    </div>
                </div>
            </div>
        </div>
    </form>
</div>
</body>
</html>